/*!
 * @file MessageSensor.cpp
 * @author Rocco Martino
 */
/***************************************************************************
 *   Copyright (C) 2014 by Rocco Martino                                   *
 *   martinorocco@gmail.com                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Lesser General Public License as        *
 *   published by the Free Software Foundation; either version 2.1 of the  *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU Lesser General Public      *
 *   License along with this program; if not, write to the                 *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

/* ======================================================================= */
/* ....................................................................... */
#include <ooGame/MessageSensor>

#include <osgODE/Notify>
/* ....................................................................... */
/* ======================================================================= */




using namespace ooGame ;




/* ======================================================================= */
/* ....................................................................... */
MessageSensor::MessageSensor(void):
    m_type          ( TEXT ),
    m_ack_internal  ( false )
{
}
/* ....................................................................... */
/* ======================================================================= */




/* ======================================================================= */
/* ....................................................................... */
MessageSensor::MessageSensor(const MessageSensor& other, const osg::CopyOp& copyop):
    Sensor          ( other, copyop ),
    m_type          ( other.m_type ),
    m_subject       ( other.m_subject ),
    m_ack_internal  ( other.m_ack_internal )
{
}
/* ....................................................................... */
/* ======================================================================= */




/* ======================================================================= */
/* ....................................................................... */
MessageSensor::~MessageSensor(void)
{
}
/* ....................................................................... */
/* ======================================================================= */




/* ======================================================================= */
/* ....................................................................... */
bool
MessageSensor::pulse( osgODE::ODEObject* object, Game* game )
{
    (void) object ;
    (void) game ;


    if( m_ack_internal ) {
        m_ack_internal = false ;
        return true ;
    }



    return false ;
}
/* ....................................................................... */
/* ======================================================================= */




/* ======================================================================= */
/* ....................................................................... */
void
MessageSensor::receiveSubject( const std::string& text )
{
    m_ack_internal |= (m_subject == ""  ||  text == m_subject) && ( m_type == TEXT ) ;
}
/* ....................................................................... */
/* ======================================================================= */




/* ======================================================================= */
/* ....................................................................... */
MessageSensor*
MessageSensor::asMessageSensor(void)
{
    return this ;
}
/* ....................................................................... */
/* ======================================================================= */
